layui.use(['form','layer','jquery'],function(){
    var form = layui.form
        layer = parent.layer === undefined ? layui.layer : top.layer,
        $ = layui.jquery;

    form.on("submit(addGoods)",function(data){
        //弹出loading
        var index = top.layer.msg('数据提交中，请稍候',{icon: 16,time:false,shade:0.8});
        // 实际使用时的提交信息
        $.ajax({
            url:'/admin/addProduct',
            data: data.field,
            processData: true,
            cache: false,
            type:'post',
            async:false,
            contentType: false,   // 不设置内容类型
            success:function (json) {
                var data = json.data;
                if(json.status == 1){
                    top.layer.close(index);
                    top.layer.msg("操作成功！");
                    layer.closeAll("iframe");
                    //刷新父页面
                    parent.location.reload();
                }
            }
        });
    });
})
